package com.autohammal.ui.frame.data;

import java.util.ArrayList;
import java.util.List;

import com.autohammal.exception.AutoHammalRuntimeException;

public class ViewerContainer<E extends Viewer> {
	List<E> proxy = new ArrayList<E>();

	public E newViewer(Class<E> clz) {
		try {
			E viewer = ((E) clz.newInstance());
			proxy.add(viewer);
			return viewer;
		} catch (Exception e) {
			throw new AutoHammalRuntimeException(e);
		}
	}

	public E get(int index) {
		return proxy.get(index);
	}

	public E remove(int index) {
		return proxy.remove(index);
	}

	public void clear() {
		proxy.clear();
	}

}
